<template>
  <el-dialog 
  v-model="dialogFormVisible" 
  title="修改物资信息" 
  top="30px"
  :close-on-click-modal="false"
  width="460px">
  <div class="form-style">
        <el-form ref="addForm" :model="form">
            <el-form-item label="名字" prop="materialName" style="width: 200px;">
                <el-input v-model="form.materialName" />
            </el-form-item> 
            <el-form-item label="数量" prop="number" style="width: 150px;">
                <el-input v-model="form.number" />
            </el-form-item>
            <el-form-item label="单位" prop="unit" style="width: 150px;">
                <el-input v-model="form.unit"/>
            </el-form-item>
            <el-form-item label="备注" prop="remark">
                <div style="width: 320px;">
                    <el-input
                    v-model="form.remark"
                    maxlength="40"
                    :rows="4"
                    show-word-limit
                    type="textarea"
                    />
                </div>
            </el-form-item>
            
        </el-form>
    </div>  
    <template #footer>
      <span class="dialog-footer">
        <el-button type="primary" @click="submitEditInfo">修改</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import { ElMessage } from "element-plus";
    export default {
        data() {
            return {
                dialogFormVisible: false,
				id:'',
				operator:'',
                form: {
                    materialName:'',
                    number:'',
                    unit:'',
                    remark:'',
                },
            };
        },
		methods: {
            //显示对话框
            dialogShow(data){
				this.dialogFormVisible=true;
				this.id=data.id;
				this.form.materialName=data.materialName;
				this.form.number=data.number;
				this.form.unit=data.unit;
				this.form.remark=data.remark;
            },
            //提交修改信息
            submitEditInfo(){
                var that=this;
                let params = {
				id:this.id,
				operator:this.operator,
                materialName:this.form.materialName,
                number:parseInt(this.form.number),
                unit:this.form.unit,
                remark:this.form.remark
                };
                this.axios
                .post("/material/update", params)
                .then(function(){
                    that.dialogFormVisible = false;
                    ElMessage({type: 'success', message: "修改成功"});
                    that.$emit("updateData");
                })
                .catch(function (error) {
					console.log(error);
                });
            },
            
        },
        mounted(){
			

        }
    };
</script>
<style scoped>
.form-style{
    margin-left: 30px;
}
</style>
